package cn.wolfcode.rbac.query;


import cn.wolfcode.rbac.domain.Department;
import lombok.Getter;
import lombok.Setter;

import java.util.Collections;
import java.util.List;

@Getter
@Setter

public class PageResult {

    public static PageResult EMPTY_PAGE= new PageResult(1,3, Collections.emptyList(),0);

    private Integer currentPage;
    private Integer pageSize;

    private List data;

    private Integer row;


    private Integer prePage;
    private Integer nextPage;
    private Integer totalPage;

    public PageResult(Integer currentPage, Integer pageSize) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
    }

    public PageResult(Integer currentPage, Integer pageSize, List data, Integer row) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.data = data;
        this.row = row;

        this.totalPage = row % pageSize == 0 ? row / pageSize : row / pageSize + 1;
        this.prePage = this.currentPage - 1 > 1 ? this.currentPage - 1 : 1;
        this.nextPage = this.currentPage + 1 < totalPage ? this.currentPage + 1 : totalPage;
    }
}
